import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import scoreatpercentile
import matplotlib.mlab as mlab
import scipy.stats as st
import csv
import random
from datetime import datetime
from time import strftime

'''
revision of test24
to calculate the false nagetive, false positive

'''

def getCurTime():
    """
    get current time
    Return value of the date string format(%Y-%m-%d %H:%M:%S)
    """
    format='%Y-%m-%d %H:%M:%S'
    sdate = None
    cdate = datetime.now()
    try:
        sdate = cdate.strftime(format)
    except:
        raise ValueError
    return sdate


def fivenum(v):
    """Returns Tukey's five number summary (minimum, lower-hinge, median, upper-hinge, maximum) for the input vector, a list or array of numbers based on 1.5 times the interquartile distance"""
    import numpy as np
    from scipy.stats import scoreatpercentile
    try:
        np.sum(v)
    except TypeError:
        print('Error: you must provide a list or array of only numbers')
    q1 = scoreatpercentile(v,25)
    q3 = scoreatpercentile(v,75)
    md = np.median(v)
    return np.min(v), q1, md, q3, np.max(v),

#--------------------------------------------------------------------------
#MAIN

if __name__ == "__main__":
    print "begin at " + getCurTime()
    #inputCSV = "C:/Documents and Settings/wang322/My Documents/My Dropbox/STAT515/proj/st_louis_mo_temp_prep.csv"
    #inputCSV = "D:/My Documents/My Dropbox/STAT515/proj/st_louis_mo_temp_prep.csv"
    inputCSV = "C:/temp.csv"
    dataMatrix = build_data_list(inputCSV) # [year, temp, prep]
    #iLen = dataMatrix.shape
    
    #print scoreatpercentile(dataMatrix[:,2],75)
    #print fivenum(dataMatrix[:,1])
    print fivenum(dataMatrix[:,2])


    print "end at " + getCurTime()
    print "========================================================================"  

           
